package com.bamboo.mcp.client.config;

import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.tool.observation.ToolCallingObservationContext;
import org.springframework.stereotype.Component;

@Component
public class ToolCallingObservationHandler  implements ObservationHandler<ToolCallingObservationContext> {
    private static final Logger logger = LoggerFactory.getLogger(ToolCallingObservationHandler.class);
    @Override
    public void onStop(ToolCallingObservationContext context) {
        logger.info("tool calling completion: \ntool calling name: \n{} \ntool calling arguments:\n{} \ntool calling result: \n{}" , context.getToolDefinition().name(), context.getToolCallArguments(), context.getToolCallResult());
    }

    @Override
    public boolean supportsContext(Observation.Context context) {
        return context instanceof ToolCallingObservationContext;

    }
}
